package com.example.asm_pro

import com.android.build.api.instrumentation.FramesComputationMode
import com.android.build.api.instrumentation.InstrumentationScope
import com.android.build.api.variant.AndroidComponentsExtension
import org.gradle.api.Plugin
import org.gradle.api.Project


class MyGradlePlugin : Plugin<Project> {
    override fun apply(project: Project) {
        val androidComponents = project.extensions.getByType(AndroidComponentsExtension::class.java)
        androidComponents.onVariants { variant ->
//            val extension = project.extensions.getByType(AsmExtension::class.java)
//            println("AsmPlugin ${extension.specificClass}")
            println("MyGradlePlugin apply")
            variant.instrumentation.setAsmFramesComputationMode(
                FramesComputationMode.COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS
            )
            variant.instrumentation.transformClassesWith(
                MyClassVisitorFactory::class.java,
                InstrumentationScope.PROJECT
            ){

            }
        }
    }
}

